package leetcode329周赛;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/1/22 12:45
 */
public class leetcode6296 {

    public static int alternateDigitSum(int n) {
        String num = n + "";
        int sum = 0;
        boolean flag = true;
        for(char c : num.toCharArray()){
            int temp = c - '0';
            sum += flag ? temp : -temp;
            flag = !flag;
        }
        return sum;
    }

    public static void main(String[] args) {
        System.out.println(alternateDigitSum(521));
    }
}
